package cn.hfjava.kz.entity.dto;

import cn.hfjava.kz.common.UpdateGroup;
import cn.hfjava.kz.common.annotation.Status;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;

import java.io.Serializable;

@Getter
@Setter
@NoArgsConstructor
@Tag(name = "UserFormDTO", description = "用户表单数据传输对象")
public class UserFormDTO implements Serializable {

    private static final long serialVersionUID = 1L;

    @Schema(description = "用户ID")
    @NotNull(groups = UpdateGroup.class, message = "Id不能为空")
    private Integer id;

    @Schema(description = "用户头像", example = "1.png")
    @NotBlank(message = "头像不能为空")
    private String avatar;

    @Schema(description = "用户名", example = "zhangsan123")
    @NotBlank(message = "用户名不能为空")
    @Pattern(regexp = "^\\w{5,12}$", message = "用户名长度为5~12个字符")
    private String username;

    @Schema(description = "用户密码", example = "password123")
    @NotBlank(message = "密码不能为空")
    @Pattern(regexp = "^\\w{6,12}$", message = "密码长度为6~12个字符")
    private String password;

    @Schema(description = "用户昵称", example = "三哥")
    @NotBlank(message = "用户昵称不能为空")
    private String nickname;

    @Schema(description = "用户手机号", example = "13800138000")
    @NotBlank(message = "手机号不能为空")
    @Pattern(regexp = "^1[3456789]\\d{9}$", message = "手机号格式错误")
    private String phone;

    @Schema(description = "用户状态", allowableValues = {"0", "1"}, example = "1")
    @Status(message = "用户状态无效", statusType = {"0", "1"})
    private Integer status;

    @Schema(description = "所属角色ID", example = "1")
    @NotNull(message = "请选择所属角色")
    private Integer roleId;
}
